<?php
/**
 * Created by PhpStorm.
 * User: lyh
 * Date: 2017/5/9
 * Time: 9:43
 */
namespace Admin\Controller;

class WorkerController extends CommonController{
    public function index(){

        $name=$_POST['name'];
        $map['name']=array('like','%'.$name.'%');
        $model=M('Doctor');
        $count= $model->count();// 查询满足要求的总记录数
        $Page = new \Think\Page($count,20);// 实例化分页类 传入总记录数和每页显示的记录数(25)
        $show = $Page->show();// 分页显示输出// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
        $doctors = $model->order('start_time desc')->where($map)->limit($Page->firstRow.','.$Page->listRows)->field('id,name,id_no,phone,start_time,status')->select();
        foreach($doctors as $k=>$v){
            $doctors[$k]['start_time']=date('Y-m-d H:i:s',$v['start_time']);
        }
        $this->assign('doctors_info',$doctors);// 赋值数据集
        $this->assign('page',$show);// 赋值分页输出
        $this->display();
    }
}